package com.viking.controller;

import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/stock")
public class StockController {

    @Value("${server.port}")
    private String serverPort;

    @RequestMapping("/reduce")
    public String reduce(){
        System.out.println("扣减库存！");
        return "ok,扣减库存,调用端口："+serverPort;
    }


    /**
     * 服务调用降级测试
     */
    @RequestMapping("/reduce2")
    public String reduce2(){
        System.out.println("扣减库存！");
        int num=1/0;
        return "ok,扣减库存,调用端口："+serverPort;
    }
}
